package com.example.work03;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import android.widget.ThemedSpinnerAdapter;

public class MainActivity extends AppCompatActivity {

    private TextView textView;
    private int count = 100;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textView = findViewById(R.id.text_time);

        //子线程
        new Thread(){
            @Override
            public void run() {

                try {


                    while(count >= 0){

                        if (count%10==0){
                            runOnUiThread(new Runnable() { //更新主线程
                                @Override
                                public void run() {
                                    textView.setText((100-count)/10*10+"%");
                                }
                            });
                        }
                        Thread.sleep(100);  //线程休眠100ms
                        count--;

                    }

                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }.start();











    }
}